/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Daniel Cruz
 */
@Entity
@Table(name = "libro")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Libro.findAll", query = "SELECT l FROM Libro l"),
    @NamedQuery(name = "Libro.findByIdLib", query = "SELECT l FROM Libro l WHERE l.idLib = :idLib"),
    @NamedQuery(name = "Libro.findByTopograficoAlfanumericoLib", query = "SELECT l FROM Libro l WHERE l.topograficoAlfanumericoLib = :topograficoAlfanumericoLib"),
    @NamedQuery(name = "Libro.findByTopograficoDecimalLib", query = "SELECT l FROM Libro l WHERE l.topograficoDecimalLib = :topograficoDecimalLib"),
    @NamedQuery(name = "Libro.findByTopograficoAlfabeticoLib", query = "SELECT l FROM Libro l WHERE l.topograficoAlfabeticoLib = :topograficoAlfabeticoLib"),
    @NamedQuery(name = "Libro.findByPaginasLib", query = "SELECT l FROM Libro l WHERE l.paginasLib = :paginasLib")})
public class Libro implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_lib")
    private Long idLib;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "topografico_alfanumerico_lib")
    private String topograficoAlfanumericoLib;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "topografico_decimal_lib")
    private BigDecimal topograficoDecimalLib;
    @Size(max = 2147483647)
    @Column(name = "topografico_alfabetico_lib")
    private String topograficoAlfabeticoLib;
    @Basic(optional = false)
    @NotNull
    @Column(name = "paginas_lib")
    private int paginasLib;
    @ManyToMany(mappedBy = "libroCollection")
    private Collection<BBasicaTipo> bBasicaTipoCollection;
    @JoinColumn(name = "material_id", referencedColumnName = "material_id")
    @ManyToOne(optional = false)
    private Material materialId;
    @JoinColumn(name = "bat_id_nivel_lectura_lib", referencedColumnName = "bat_id")
    @ManyToOne
    private BBasicaTipo batIdNivelLecturaLib;
    @JoinColumn(name = "bat_id_genero_lib", referencedColumnName = "bat_id")
    @ManyToOne(optional = false)
    private BBasicaTipo batIdGeneroLib;

    public Libro() {
    }

    public Libro(Long idLib) {
        this.idLib = idLib;
    }

    public Libro(Long idLib, String topograficoAlfanumericoLib, BigDecimal topograficoDecimalLib, int paginasLib) {
        this.idLib = idLib;
        this.topograficoAlfanumericoLib = topograficoAlfanumericoLib;
        this.topograficoDecimalLib = topograficoDecimalLib;
        this.paginasLib = paginasLib;
    }

    public Long getIdLib() {
        return idLib;
    }

    public void setIdLib(Long idLib) {
        this.idLib = idLib;
    }

    public String getTopograficoAlfanumericoLib() {
        return topograficoAlfanumericoLib;
    }

    public void setTopograficoAlfanumericoLib(String topograficoAlfanumericoLib) {
        this.topograficoAlfanumericoLib = topograficoAlfanumericoLib;
    }

    public BigDecimal getTopograficoDecimalLib() {
        return topograficoDecimalLib;
    }

    public void setTopograficoDecimalLib(BigDecimal topograficoDecimalLib) {
        this.topograficoDecimalLib = topograficoDecimalLib;
    }

    public String getTopograficoAlfabeticoLib() {
        return topograficoAlfabeticoLib;
    }

    public void setTopograficoAlfabeticoLib(String topograficoAlfabeticoLib) {
        this.topograficoAlfabeticoLib = topograficoAlfabeticoLib;
    }

    public int getPaginasLib() {
        return paginasLib;
    }

    public void setPaginasLib(int paginasLib) {
        this.paginasLib = paginasLib;
    }

    @XmlTransient
    public Collection<BBasicaTipo> getBBasicaTipoCollection() {
        return bBasicaTipoCollection;
    }

    public void setBBasicaTipoCollection(Collection<BBasicaTipo> bBasicaTipoCollection) {
        this.bBasicaTipoCollection = bBasicaTipoCollection;
    }

    public Material getMaterialId() {
        return materialId;
    }

    public void setMaterialId(Material materialId) {
        this.materialId = materialId;
    }

    public BBasicaTipo getBatIdNivelLecturaLib() {
        return batIdNivelLecturaLib;
    }

    public void setBatIdNivelLecturaLib(BBasicaTipo batIdNivelLecturaLib) {
        this.batIdNivelLecturaLib = batIdNivelLecturaLib;
    }

    public BBasicaTipo getBatIdGeneroLib() {
        return batIdGeneroLib;
    }

    public void setBatIdGeneroLib(BBasicaTipo batIdGeneroLib) {
        this.batIdGeneroLib = batIdGeneroLib;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLib != null ? idLib.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Libro)) {
            return false;
        }
        Libro other = (Libro) object;
        if ((this.idLib == null && other.idLib != null) || (this.idLib != null && !this.idLib.equals(other.idLib))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Libro[ idLib=" + idLib + " ]";
    }
    
}
